package cn.tedu.mall.product.redis.preload;

import cn.tedu.mall.product.service.IBrandService;
import cn.tedu.mall.product.service.ICategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 缓存预热
 */
@Component
@Slf4j
public class CachePreLoad implements ApplicationRunner {

    @Autowired
    private IBrandService brandService;
    @Autowired
    private ICategoryService categoryService;

    @Override
    public void run(ApplicationArguments args) {
        log.debug("缓存预热，准备向Redis中写入品牌数据……");
        brandService.initCache();
        log.debug("缓存预热，准备向Redis中写入类别数据……");
        categoryService.initCache();
    }

}
